home *** CD-ROM | disk | FTP | other *** search
- /*-------------------------------------------------------------------
-
- AOCE Post Office Protocol (POP) / Simple Mail Transfer Protocol (SMTP)
- Mail Service Access Module
-
- written by Steve Falkenburg-- MacDTS
- ©1991-1993 Apple Computer, Inc.
-
- --------------
- change history
- --------------
-
- SJF 02/19/93 update for beta build b1
- SJF 10/29/92 update to a11 a11
- SJF 06/08/92 update to a8 a8
- SJF 02/15/92 first working version a4.5
- SJF 10/16/91 initial coding a3
-
- ---------------------------------------------------------------------*/
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __GESTALTEQU__
- #include <GestaltEqu.h>
- #endif
-
- #ifndef __TRAPS__
- #include <Traps.h>
- #endif
-
- #ifndef __PACKAGES__
- #include <Packages.h>
- #endif
-
- #ifndef _GestaltDispatch
- #define _GestaltDispatch _Gestalt
- #endif
-
- #include "const.h"
- #include "mytypes.h"
- #include "gwerrors.h"
- #include "globals.h"
- #include "trapavailable.h"
- #include "main.h"
- #include "utils.h"
-
- Boolean SupportsAEVT(void)
- {
- OSErr err;
- long response;
-
- if (!TrapAvailable(_GestaltDispatch))
- return false;
-
- err = Gestalt(gestaltAppleEventsAttr,&response);
- if (err!=noErr)
- return false;
-
- return (response && (response << gestaltAppleEventsPresent));
- }
-
-
- void pstrcpy(void *dest,void *src)
- {
- unsigned char srcLen = ((unsigned char *)src)[0];
-
- BlockMove(src,dest,srcLen+1);
- }
-
-
- void pstrcat(void *original,void *catStr)
- {
- short length;
- unsigned char originalLen = ((unsigned char *)original)[0];
- unsigned char catStrLen = ((unsigned char *)catStr)[0];
-
- length = (short) originalLen;
- length += (short) catStrLen;
-
- #ifdef kDEBUG
- if (length > 255) {
- DebugStr("\pstring catenation overflow");
- ExitProc();
- }
- #endif
-
- BlockMove((char *)catStr+1,(char *)original+originalLen+1,catStrLen);
- ((unsigned char *)original)[0] = (unsigned char) length;
- }
-
-
- void *NewPtrChk(Size ptrSize)
- {
- Ptr thePtr;
-
- thePtr = NewPtr(ptrSize);
- if (MemError()!=noErr)
- DoError(MemError());
- #if kDEBUG
- {
- long *longPtr = (long *)thePtr;
- *longPtr = kBetterBusErr;
- }
- #endif
- return thePtr;
- }
-
-
- void *NewHandleChk(Size hndlSize)
- {
- Handle theHndl;
-
- theHndl = NewHandle(hndlSize);
- if (MemError()!=noErr)
- DoError(MemError());
- #if kDEBUG
- {
- long **longHndl = (long **)theHndl;
- **longHndl = kBetterBusErr;
- }
- #endif
- return theHndl;
- }
-
-
- void DisposPtrChk(void *thePtr)
- {
- #if kDEBUG
- {
- long *longPtr = (long *)thePtr;
- *longPtr = kBetterBusErr;
- }
- #endif
-
- DisposPtr(thePtr);
- if (MemError()!=noErr)
- DoError(MemError());
- }
-
-
- void DisposHandleChk(void *theHndl)
- {
- #if kDEBUG
- {
- long **longHndl = (long **)theHndl;
- **longHndl = kBetterBusErr;
- }
- #endif
-
- DisposHandle(theHndl);
- if (MemError()!=noErr)
- DoError(MemError());
- }
-
-
- OSErr WaitPBDone(void *voidBlock)
- {
- IOParam *pBlock;
- #ifdef kDEBUG
- Str255 errStr;
- #endif
-
- pBlock = (IOParam *)voidBlock;
-
- if (gWakeUpSecondary==false) {
- while (pBlock->ioResult == 1)
- SecondaryEventLoop();
- while (gWakeUpSecondary==false)
- ;
- }
-
- gWakeUpSecondary = false; // set to false for next invocation
-
- #ifdef kDEBUG
- if (pBlock->ioResult!=noErr) {
- NumToString(pBlock->ioResult,errStr);
- pstrcat(errStr,"\p ******** ERROR ********");
- DebugStr(errStr);
- }
- #endif
-
- return pBlock->ioResult;
- }
-
-
- void ClearBuffer(void *buff,Size length)
- {
- unsigned long index;
- char *clrBuff;
-
- clrBuff = (char *)buff;
- for (index=0; index<length; index++)
- clrBuff[index] = 0;
- }
-